﻿
/// <reference path="_namespace.js" />
/// <reference path="Animation.js" />


/*****************************************************************************
Ajax library class definition. Kevin Robinson 2006.
Class: ajax.effects.NotifyFlash
/*****************************************************************************/

ajax.lang.addNamespace("ajax.effects");

//-----------------------------------------------------------------------------
ajax.effects.NotifyFlash = function(doc, ele, speed)
{
    ajax.effects.NotifyFlash.superConstructor.call(this, doc, Math.max(1, speed));
    
    this.element    = ele;    
    this.color      = ajax.lang.safeNew("ajax.drawing.Colour", 255, 255, 255); // White
    this.saturation = 0;
    this.step       = 2;
    this.callback   = this.doFlash.bind(this);
}

//-----------------------------------------------------------------------------
ajax.lang.extend("ajax.effects.NotifyFlash", "ajax.effects.Animation"); // Inherit
//-----------------------------------------------------------------------------

ajax.effects.NotifyFlash.prototype.doFlash = function()
{
    this.color.b = this.saturation;
    this.element.style.backgroundColor = this.color.value;
    
    if (this.color.b < 255)
    {        
        this.saturation += this.step;
        this.color.update();        
    }
    else            
        this.stop(); // Stop looping                
}

//-----------------------------------------------------------------------------
ajax.effects.NotifyFlash.prototype.toString = function()
{
    return "ajax.effects.NotifyFlash";
}

//-----------------------------------------------------------------------------
ajax.effects.NotifyFlash.cast = function(obj)
{///<returns type="ajax.effects.NotifyFlash"/>
    return obj;    
}
